import request from '../request.ts'

// 创建题目
export const createQuestion = (data) => {
  return request({
    url: '/questions/create',
    method: 'post',
    data
  })
}

// 获取题目详情
export const getQuestion = (questionId) => {
  return request({
    url: `/questions/${questionId}`,
    method: 'get'
  })
}

// 更新题目
export const updateQuestion = (questionId, data) => {
  return request({
    url: `/questions/${questionId}`,
    method: 'put',
    data
  })
}

// 删除题目
export const deleteQuestion = (questionId) => {
  return request({
    url: `/questions/${questionId}`,
    method: 'delete'
  })
}

// 获取我的题目列表
export const listMyQuestions = () => {
  return request({
    url: '/questions/my',
    method: 'get'
  })
}

// 根据课程ID获取题目列表
export const listQuestionsByCourse = (courseId) => {
  return request({
    url: `/questions/course/${courseId}`,
    method: 'get'
  })
}

// 获取题目列表（支持分页和筛选）
export const getQuestions = (params) => {
  return request({
    url: '/questions',
    method: 'get',
    params
  })
}

// 搜索题目
export const searchQuestions = (params) => {
  return request({
    url: '/questions/search',
    method: 'get',
    params
  })
}
